package com.dragon.datastructure.tree.segment;

/**
 * 线段树测试
 *
 * @author dragon
 * @since 2020/1/2
 */
public class SegmentTreeTest {

    public static void main(String[] args) {
        Integer[] array = {2, 0, -1, 200, 100, 9, 10};
        SegmentTree<Integer> segmentTree = new SegmentTree<>(array, (a, b) -> a + b);
        System.out.println(segmentTree);

        System.out.println(segmentTree.query(0, 2));
        System.out.println(segmentTree.query(1, 5));
        System.out.println(segmentTree.query(2, 6));

        segmentTree.set(0, 1);
        System.out.println(segmentTree);

        System.out.println(segmentTree.query(0, 2));
    }
}
